// LogComponent.js
import React, { useState } from 'react';
import axios from 'axios';
axios.defaults.baseURL = 'http://127.0.0.1:3000/zlq'
const LogComponent = () => {
  const [operator, setOperator] = useState('张三');
  const [ipAddress, setIpAddress] = useState('192.100.200.102');
  const [responseTime, setResponseTime] = useState(150);
  
  const handleLogSubmit = async () => {
    const logData = {
      operator,
      ipAddress,
      requestUrl: '/system/user',
      requestMethod: 'POST',
      operationMethod: 'com.ruoyi.web.controller.system.SysUserController.add()',
      requestParams: { admin: false, userName: '450450' },
      responseTime
    };

    try {
      const response = await axios.post('/journaladd', logData);
      alert(response.data.message);
    } catch (error) {
      console.error('Error sending log:', error);
      alert('Failed to save log');
    }
  };

  return (
    <div>
      <h2>日志记录</h2>
      <button onClick={handleLogSubmit}>记录日志</button>
    </div>
  );
};

export default LogComponent;
